<template>
  <div class="fj">
    <h1 class="centet">注册</h1>
          

    <el-form ref="form" id="fiim" :model="form" :rules="rules" label-width="80px">
      <el-row>
        <el-col :span="6">
          <el-form-item label="用户昵称" prop="nickName">
            <el-input v-model="form.nickName" placeholder="请输入用户昵称" />
          </el-form-item>
        </el-col>
      </el-row>
      <el-row>
        <el-col :span="6">
          <el-form-item label="手机号码" prop="phonenumber">
            <el-input
              v-model="form.phonenumber"
              placeholder="请输入手机号码"
              maxlength="11"
            />
          </el-form-item>
        </el-col>
      </el-row>
      <el-row>
        <el-col :span="6">
          <el-form-item label="邮箱" prop="email">
            <el-input
              v-model="form.email"
              placeholder="请输入邮箱"
              maxlength="50"
            />
          </el-form-item>
        </el-col>
      </el-row>
      <el-row>
        <el-col :span="6">
          <el-form-item
            v-if="form.userId == undefined"
            label="用户名称"
            prop="userName"
          >
            <el-input v-model="form.userName" placeholder="请输入用户名称" />
          </el-form-item>
        </el-col>
      </el-row>
      <el-row>
        <el-col :span="6">
          <el-form-item
            v-if="form.userId == undefined"
            label="用户密码"
            prop="password"
          >
            <el-input
              v-model="form.password"
              placeholder="请输入用户密码"
              type="password"
            />
          </el-form-item>
        </el-col>
      </el-row>
      <el-row>
        <el-col :span="6">
          <el-form-item label="用户性别">
            <el-select v-model="form.sex" placeholder="请选择">
              <el-option
                v-for="dict in sexOptions"
                :key="dict.dictValue"
                :label="dict.dictLabel"
                :value="dict.dictValue"
              ></el-option>
            </el-select>
          </el-form-item>
        </el-col>
      </el-row>

      <el-row>
        <el-col :span="6">
          <el-form-item label="备注">
            <el-input
              v-model="form.remark"
              type="textarea"
              placeholder="请输入内容"
            ></el-input>
          </el-form-item>
        </el-col>
      </el-row>
    </el-form>
    <div slot="footer" class="dialog-footer">
      <el-button type="primary" @click="submitForm">确 定</el-button>
      <el-button @click="cancel">取 消</el-button>
    </div>
  </div>
</template>

<script>
    import {adduser} from '@/api/zhu/index.js'
    export default {
        name:'Register',
        data(){
            return {
                title:'注册',
                open:true,
                 sexOptions:[{
                                dictLabel:'男',
                                dictValue:'男'
                            },
                            {
                                dictLabel:'女',
                                dictValue:'女'
                            },
                            ],
                form:{
                   
                },
                rules:{
 userName: [
          { required: true, message: "用户名称不能为空", trigger: "blur" }
        ],
        nickName: [
          { required: true, message: "用户昵称不能为空", trigger: "blur" }
        ],
        password: [
          { required: true, message: "用户密码不能为空", trigger: "blur" }
        ],
        email: [
          {
            type: "email",
            message: "'请输入正确的邮箱地址",
            trigger: ["blur", "change"]
          }
        ],
        phonenumber: [
          {
            pattern: /^1[3|4|5|6|7|8|9][0-9]\d{8}$/,
            message: "请输入正确的手机号码",
            trigger: "blur"
          }
        ]
      }
                

            }
        },
        methods:{
            submitForm(){
                adduser(this.form).then(res=>{
                    console.log("提交成功");
                     this.msgSuccess("注册成功");
                    this.$router.push(
            {
                path:'/login'
            }
                    )
                })
            },
            reset() {
      this.form = {
        userId: undefined,
        deptId: undefined,
        userName: undefined,
        nickName: undefined,
        password: undefined,
        phonenumber: undefined,
        email: undefined,
        sex: undefined,
        status: "0",
        remark: undefined,
        postIds: [],
        roleIds: []
      };
      this.resetForm("form");
    },
    cancel(){
        this.$router.push(
            {
                path:'/login'
            }
                    )
    }
            
        }
    }
</script>

<style lang="scss" rel="stylesheet/scss">
.centet{
    // padding-left: 200px;
}
.fj{
    
    padding: 20px;
    // padding-left: 30%;
    background-image: url("./zhu/image/1094664.jpg");
    height: 100vh;
    background-repeat: no-repeat;
    background-position: center;
    background-size: cover;
    color: white;
}
#fiim label.el-form-item__label,#fiim input.el-input__inner,#fiim .el-textarea__inner{
    color: white;
}
#fiim .el-input__inner,#fiim .el-textarea__inner{
    background-color: rgba(0,0,0,0.1);
}
</style>